<?php
/*
 *   This file is part of Verbum.
 *
 *   poat is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   poat is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with poat.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * 	 Copyright (c) 2008 Sergio Gabriel Teves <gabriel.sgt at gmail.com>
 */
 
 	if (!defined('LOG4PHP_CONFIGURATION')) {
 		define("LOG4PHP_CONFIGURATION",ROOT_PATH."configs/logger.xml");	
 	}
	define("LOG4PHP_DIR",ROOT_PATH."log4php");
	
	require_once(LOG4PHP_DIR.'/LoggerManager.php');

	set_error_handler('errorHandler');
	
	function errorHandler ($errno, $errstr, $errfile, $errline, $errcontext) {
	   $logger =& LoggerManager::getLogger('system');
	   $msg = "[$errno] $errstr - $errfile:$errline";
	   switch ($errno)
	   {
	      case E_USER_WARNING:
	      case E_WARNING:
	      case E_CORE_WARNING:
	      case E_COMPILE_WARNING:
	      	$logger->warn($msg);
	         break;
	      case E_USER_NOTICE:
	      case E_NOTICE:
	      	$logger->info($msg);
	      	break;
	      case E_USER_ERROR:
	      case E_ERROR:
	      case E_PARSE:
	      case E_CORE_ERROR:
	      case E_COMPILE_ERROR:
	      	$logger->error($msg);
	      	break;
	   }
	}
?>
